package com.hx.io.filereader;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.Reader;

/**
 * @author jxlgcmh
 * @create 2019-05-09 15:27
 */
public class ReaderDemo2 {
    public static void main(String[] args) {
        //注意相对路径问题  project与module的不同
        Reader reader = null;
        try {// 88888
            reader = new FileReader("a.txt");
            int data;
            while ((data = reader.read()) != -1) {
                System.out.print((char) data);
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {//如果在88888处发生异常，不进行非空判断，会报有空指针异常
            if (reader != null) {
                try {
                    reader.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }


    }
}
